// 供应商相关API
window.supplierAPI = {
    // 获取供应商列表
    getSuppliers: async (params = {}) => {
        try {
            const response = await apiClient.get('/api/suppliers/', { params });
            return response;
        } catch (error) {
            console.error('获取供应商列表失败:', error);
            throw error;
        }
    },
    
    // 获取供应商详情
    getSupplier: async (id) => {
        try {
            const response = await apiClient.get(`/api/suppliers/${id}`);
            return response;
        } catch (error) {
            console.error('获取供应商详情失败:', error);
            throw error;
        }
    },
    
    // 创建供应商
    createSupplier: async (data) => {
        try {
            const response = await apiClient.post('/api/suppliers', data);
            return response;
        } catch (error) {
            console.error('创建供应商失败:', error);
            throw error;
        }
    },
    
    // 更新供应商
    updateSupplier: async (id, data) => {
        try {
            const response = await apiClient.put(`/api/suppliers/${id}`, data);
            return response;
        } catch (error) {
            console.error('更新供应商失败:', error);
            throw error;
        }
    },
    
    // 删除供应商
    deleteSupplier: async (id) => {
        try {
            const response = await apiClient.delete(`/api/suppliers/${id}`);
            return response;
        } catch (error) {
            console.error('删除供应商失败:', error);
            throw error;
        }
    },
    
    // 批量删除供应商
    batchDeleteSuppliers: async (ids) => {
        try {
            const response = await apiClient.post('/api/suppliers/batch-delete', { ids });
            return response;
        } catch (error) {
            console.error('批量删除供应商失败:', error);
            throw error;
        }
    },
    
    // 获取所有供应商（下拉选择）
    getAllSuppliers: async () => {
        try {
            const response = await apiClient.get('/api/suppliers/all');
            return response;
        } catch (error) {
            console.error('获取所有供应商失败:', error);
            throw error;
        }
    }
};
